﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;

namespace WindowsFormsApp1
{
   public  class DBHelper
    {
        private static string conString = "server=.;database=Students;uid=sa;pwd=525200wai;";
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
            DataTable dt = new DataTable();
            connection.Open();
            adapter.Fill(dt);
            return dt;
        }
        public static int AddOrUqdateOrDelete(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            return command.ExecuteNonQuery();
        }

    }
}
